home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TPUG - Toronto PET Users Group
/
TPUG Users Group CD
/
TPUG Users Group CD.iso
/
AMIGA
/
AMICUS
/
AMICUS09.ADF
/
AmigaBasicProgs
/
FlightSim
(
.txt
)
< prev
next >
Wrap
AmigaBASIC Source Code
|
1986-05-22
|
3KB
|
146 lines
CLS
PRINT "This is a simple flight simulator written in AmigaBasic."
PRINT "It uses the joystick in port 2 to control the plane."
PRINT "The joystick button increases the throttle, and the 'g'"
PRINT "key on the keyboard raises or lowers the landing gear."
PRINT "Press any key to start"
WHILE INKEY$ = ""
WEND
ON TIMER(1) GOSUB Inst
TIMER ON
rpt=0
ld=INT(RND*360)
GOTO Loop
Display:
ev=INT(elev/10)
GOSUB Roll
clock=clock+1
LOCATE 1,1:PRINT x$
RETURN
Roll: ' With Pitch and ground
r=INT(wa*10+50)
p=ev*2
IF ((98-r)+p)<=0 OR r+p<=0 THEN RETURN
COLOR 3
AREA (25,(98-r)+p):AREA (600,r+p):AREA (600,98):AREA (25,98): AREAFILL
COLOR 0
AREA (25,(98-r)+p):AREA (600,r+p):AREA (600,2): AREA (25,2): AREAFILL
RETURN
Inst:
COLOR 3
LOCATE 15,5:PRINT ang,INT(airspd),INT(alt),INT(fuel),ld,elev;
LOCATE 17,11:PRINT INT((clock)/10);:LOCATE 17,35
IF uflag=1 THEN PRINT "DOWN" :ELSE PRINT "UP "
RETURN
Stickinp:
IF STRIG(3)=-1 THEN airspd=airspd+3
horiz=STICK(2)
vert=STICK(3)
RETURN
Loop:
CLS
COLOR 1
LINE (23,100)-(602,0),,b
LOCATE 14,5: PRINT"Heading","Airspeed","Altitude","Fuel","Dest","Elev","Time"
LOCATE 17,5: PRINT "Clock:": LOCATE 17,22: PRINT "Landing Gear "
GOSUB Init
SAY TRANSLATE$("Get ready for take off")
Main:
IF crash=0 THEN
IF wa>0 THEN wa=wa-0.2
IF wa<0 THEN wa=wa+0.2
IF ang<0 THEN ang=ang+360
IF ang>360 THEN ang=ang-360
END IF
GOSUB Display
IF crash=1 THEN COLOR 1:END
SOUND 110+airspd/10,2
SOUND 120+airspd/10,2
IF land=1 AND uflag=1 THEN CLS:PRINT "Good landing, sir!":END
IF land=1 AND uflag=0 THEN PRINT"Your wheels were UP":GOSUB Crunch:GOTO Main
t=airspd : stall=0
In:
x$=INKEY$
IF takeoff=1 THEN elev=INT(elev+RND*2-RND*2)
GOSUB Stickinp
IF airspd<3 THEN GOTO Airspeed
IF vert=1 THEN elev=elev+4:eflag=4:IF elev>90 THEN stall=1
IF vert=-1 THEN elev=elev-4:eflag=-4:IF elev<-90 THEN stall=-1
IF stall=1 THEN
SOUND 1000,10
airspd=airspd/4
END IF
IF stall=-1 THEN
SOUND 500,10
alt=4*alt/5
END IF
IF alt<1 THEN GOTO Airspeed
GOSUB Stickinp
IF horiz=-1 THEN wa=wa-1:ang=ang-6:IF wa<-3 THEN wa=-3
IF horiz=1 THEN wa=wa+1:ang=ang+6:IF wa>3 THEN wa=3
ang=INT(ang+RND*2-RND*2)
Airspeed:
IF x$="." THEN airspd=airspd+8
IF x$="," THEN airspd=airspd-7
IF x$=" " THEN airspd=0
airspd=airspd-elev/100
IF uflag=1 THEN airspd=airspd-0.5:fuel=fuel-0.1
IF airspd<0 THEN airspd=0
IF airspd>400 THEN airspd=400
IF x$="g" AND uflag=0 THEN uflag=1:GOTO Chkfuel:
IF x$="g" AND uflag=1 THEN uflag=0
Chkfuel:
fuel=fuel-(ABS(t-airspd)/100)-0.1
IF fuel<1 THEN GOSUB Crunch
IF takeoff=1 THEN GOTO Notoff
IF elev>10 AND airspd>45 AND uflag=1 THEN takeoff=1
IF takeoff=0 THEN alt=0:GOTO Chkalt
Notoff:
IF land=0 AND airspd<30 THEN elev=elev-5
alt=alt+INT(((elev+0.1)*airspd)+eflag*airspd/1000)/40
IF alt<300 AND takeoff=1 THEN alt=alt+airspd/30+elev
Chkalt:
IF alt<0 THEN GOSUB Crunch
IF (alt>15 AND airspd>20) OR takeoff=0 THEN GOTO Main
IF ABS(ang-ld)<13 OR ABS(ang+360-ld)<13 THEN land=1:GOTO Main
GOTO Main
Init:
uflag=1 ' landing gear up or down
eflag=1
ang=0
takeoff=0
land=0
airspd=0
alt=0 ' altitude
elev=0
wa=0
fuel=750
crash=0
clock=0
x$=""
RETURN
Crunch:
crash=1
alt=0
col=3
GOSUB Inst
SAY TRANSLATE$("Sorry, you crashed")
COLOR 1
RETURN